from selenium import webdriver
from lianxi.xiecheng.base import base
from selenium.webdriver.common.by import By

class login_page(base):
    login1 = (By.XPATH, '/html/body/div[2]/div/ul[2]/li[1]/a/span')#点击首页登录
    login2 = (By.CLASS_NAME, 'agreement-checkbox')#点击我同意
    login3 = (By.XPATH, '/html/body/div[3]/div[2]/div/div[1]/div[5]/div[2]/a[2]')#点击qq
    login4 = (By.XPATH, '/html/body/div[2]/div[1]/div/iframe')#iframe
    login5 = (By.LINK_TEXT, '帐号密码登录')#点击帐号密码登录
    login6 = (By.ID, 'u')#输入账号
    login7 = (By.NAME, 'p')#输入密码
    login8 = (By.ID, 'login_button')#点击授权登录
    url = 'https://www.ctrip.com/'    # 网址
    text1 = '1547786171'# 输入账号
    text2 = 'chenxinyang.0827'# 输入密码

    def login(self):

        self.get_url(self.url)
        self.get_sleep()
        self.get_click(*self.login1)
        self.get_sleep()
        self.get_click(*self.login2)
        self.get_sleep()
        self.get_click(*self.login3)
        self.get_sleep()
        self.get_jb(-1)
        self.get_frame(*self.login4)
        self.get_sleep()
        self.get_click(*self.login5)
        self.get_sleep()
        self.get_text(self.text1,*self.login6)
        self.get_sleep()
        self.get_text(self.text2, *self.login7)
        self.get_sleep()
        self.get_click(*self.login8)
        self.get_sleep(5)
        self.get_jb(0)
        self.store_cookie()
